/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entidade;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Lomanda
 */
@Entity
@Table(name = "tbfornecedorstock")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "FornecedorStock.findAll", query = "SELECT f FROM FornecedorStock f"),
    @NamedQuery(name = "FornecedorStock.findById", query = "SELECT f FROM FornecedorStock f WHERE f.id = :id"),
    @NamedQuery(name = "FornecedorStock.findByNome", query = "SELECT f FROM FornecedorStock f WHERE f.nome = :nome"),
    @NamedQuery(name = "FornecedorStock.findByTelemovel", query = "SELECT f FROM FornecedorStock f WHERE f.telemovel = :telemovel"),
    @NamedQuery(name = "FornecedorStock.findByEmail", query = "SELECT f FROM FornecedorStock f WHERE f.email = :email"),
    @NamedQuery(name = "FornecedorStock.findByEndereco", query = "SELECT f FROM FornecedorStock f WHERE f.endereco = :endereco"),
    @NamedQuery(name = "FornecedorStock.findByDetalhes", query = "SELECT f FROM FornecedorStock f WHERE f.detalhes = :detalhes")})
public class FornecedorStock implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 150)
    @Column(name = "nome")
    private String nome;
    @Size(max = 45)
    @Column(name = "telemovel")
    private String telemovel;
    // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
    @Size(max = 45)
    @Column(name = "email")
    private String email;
    @Size(max = 45)
    @Column(name = "endereco")
    private String endereco;
    @Size(max = 150)
    @Column(name = "detalhes")
    private String detalhes;
    @ManyToMany(mappedBy = "fornecedorStockList")
    private List<ProdutoStock> produtoStockList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fkFornecedor")
    private List<EncomendaStock> encomendaStockList;

    public FornecedorStock() {
    }

    public FornecedorStock(Integer id) {
        this.id = id;
    }

    public FornecedorStock(Integer id, String nome) {
        this.id = id;
        this.nome = nome;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public String getTelemovel() {
        return telemovel;
    }

    public void setTelemovel(String telemovel) {
        this.telemovel = telemovel;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getEndereco() {
        return endereco;
    }

    public void setEndereco(String endereco) {
        this.endereco = endereco;
    }

    public String getDetalhes() {
        return detalhes;
    }

    public void setDetalhes(String detalhes) {
        this.detalhes = detalhes;
    }

    @XmlTransient
    public List<ProdutoStock> getProdutoStockList() {
        return produtoStockList;
    }

    public void setProdutoStockList(List<ProdutoStock> produtoStockList) {
        this.produtoStockList = produtoStockList;
    }

    @XmlTransient
    public List<EncomendaStock> getEncomendaStockList() {
        return encomendaStockList;
    }

    public void setEncomendaStockList(List<EncomendaStock> encomendaStockList) {
        this.encomendaStockList = encomendaStockList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof FornecedorStock)) {
            return false;
        }
        FornecedorStock other = (FornecedorStock) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidade.FornecedorStock[ id=" + id + " ]";
    }
    
}
